package tech.waterism.enums;

/**
 * 执行状态
 */
public enum ExecuteStatusEnum {
    FINISH("完成", 0),
    INIT("新建", 1),
    RUNNING("执行中", 2),
    FINISH_ABNORMAL("异常结束", (3)),
    READY("数据准备完成", 4),
    ABORT("放弃执行", 5),
    UNDER_TEST("测试中", 6),
    FINISH_TEST("测试完成", 7);

    private final String name;
    private final Integer status;

    ExecuteStatusEnum(String name, Integer status) {
        this.name = name;
        this.status = status;
    }

    public static String getName(Integer status) {
        for (ExecuteStatusEnum c : ExecuteStatusEnum.values()) {
            if (c.getStatus().equals(status)) {
                return c.name;
            }
        }
        return null;
    }

    public static ExecuteStatusEnum getStatus(Integer status) {
        for (ExecuteStatusEnum c : ExecuteStatusEnum.values()) {
            if (c.getStatus().equals(status)) {
                return c;
            }
        }
        return null;
    }

    public Integer getStatus() {
        return status;
    }
}
